import pymysql


def query_mysql(sql):
    conn = pymysql.connect(host='localhost', user='root',
        password='123456', db='pig', charset='utf8')
    cursor = conn.cursor()
    cursor.execute(sql)
    results = cursor.fetchall()
    conn.close()
    return results

if __name__ == "__main__":
    print('开始执行')
    rf = query_mysql('select * from sys_menu')
    for rows in  rf:
        print(rows)
        print(rows[1])